import math


class Solution(object):
    def minEatingSpeed(self, piles, h):
        n = len(piles)

        def search(value):
            c = 0
            for pile in piles:
                c += math.ceil(pile / value)
            return c

        left = 1
        right = max(piles)
        while left < right:
            mid = (left + right) // 2
            e = search(mid)
            if e <= h:
                right = mid
            else:
                left = mid + 1
        return left